<?php
/**
 * Created by PhpStorm.
 * User: Lenovo
 * Date: 2019/4/27
 * Time: 19:28
 */

namespace app\api\controller;
use app\api\model\UserModel;


use think\Controller;

class Test extends Controller
{
  public function __construct()
  {
   header("Access-Control-Allow-Origin: *");
  }
   public function index()
   {
     $rand=time().rand(0000,9999);
   	return $rand;
   }
  public function binduser()
  {
  	$rand=input('rand');
    $uid=input('uid');
    $user=UserModel::where('uid',$uid)->find();
    if($rand!=$user['login_rand']){
    	$re=UserModel::where('uid',$uid)->update([
    	'login_rand'=>$rand
        ]);
        if($re){
            return 1;
        }else{
            return 0;
        }
    }
    return 1;
  }
}